package y23.Oct;

class MyThread2 extends Thread{
    public void run(){
        while(true){
            System.out.println("Thread");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
class MyRunnable2 implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("Runnable");
            try {
                Thread.sleep(400);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class Test21 {
    public static void main(String[] args) {
     MyRunnable2 myRunnable = new MyRunnable2();
     Thread thread = new Thread(myRunnable);
     MyThread2 myThread2 = new MyThread2();
     thread.start();
     myThread2.start();
     while (true){
         System.out.println("main");
         try {
             Thread.sleep(800);
         } catch (InterruptedException e) {
             throw new RuntimeException(e);
         }
     }
    }
}
